<template>
  <div class="learning-roadmap-section" v-if="roadmapData">
    <h3>学习路径规划</h3>
    <div class="roadmap-timeline">
      <div class="timeline-item immediate" v-if="roadmapData.immediate_fixes">
        <div class="timeline-header">
          <h4>立即改进</h4>
          <span class="timeline-duration">1-2周</span>
        </div>
        <div class="timeline-content">
          <div v-for="fix in roadmapData.immediate_fixes" :key="fix.issue" class="roadmap-item">
            <div class="issue">{{ fix.issue }}</div>
            <div class="solution">{{ fix.solution }}</div>
            <div class="resources" v-if="fix.resources">
              <span v-for="resource in fix.resources" :key="resource" class="resource-tag">{{ resource }}</span>
            </div>
          </div>
        </div>
      </div>

      <div class="timeline-item short-term" v-if="roadmapData.short_term_goals">
        <div class="timeline-header">
          <h4>短期目标</h4>
          <span class="timeline-duration">1-2个月</span>
        </div>
        <div class="timeline-content">
          <div v-for="goal in roadmapData.short_term_goals" :key="goal.goal" class="roadmap-item">
            <div class="goal">{{ goal.goal }}</div>
            <div class="actions" v-if="goal.action_steps">
              <span v-for="action in goal.action_steps" :key="action" class="action-tag">{{ action }}</span>
            </div>
          </div>
        </div>
      </div>

      <div class="timeline-item long-term" v-if="roadmapData.long_term_mastery">
        <div class="timeline-header">
          <h4>长期掌握</h4>
          <span class="timeline-duration">3-6个月</span>
        </div>
        <div class="timeline-content">
          <div v-for="mastery in roadmapData.long_term_mastery" :key="mastery.goal" class="roadmap-item">
            <div class="goal">{{ mastery.goal }}</div>
            <div class="techniques" v-if="mastery.advanced_techniques">
              <span v-for="technique in mastery.advanced_techniques" :key="technique"
                class="technique-tag">{{ technique }}</span>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'LearningRoadmap',
  props: {
    roadmapData: {
      type: Object,
      default: null
    }
  }
};
</script>

<style scoped>
.learning-roadmap-section {
  margin: 40px 0;
  padding: 30px;
  background: linear-gradient(135deg, #f8f9fa, #e9ecef);
  border-radius: 16px;
  border-left: 4px solid #6f42c1;
}

.learning-roadmap-section h3 {
  color: #6f42c1;
  margin-bottom: 30px;
  font-size: 1.4rem;
  text-align: center;
}

.roadmap-timeline {
  position: relative;
}

.roadmap-timeline::before {
  content: '';
  position: absolute;
  left: 30px;
  top: 0;
  bottom: 0;
  width: 3px;
  background: linear-gradient(to bottom, #ff6b6b, #feca57, #48dbfb);
  border-radius: 2px;
}

.timeline-item {
  position: relative;
  margin-bottom: 40px;
  padding-left: 80px;
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: 18px;
  top: 10px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 3px solid white;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.timeline-item.immediate::before {
  background: #ff6b6b;
}

.timeline-item.short-term::before {
  background: #feca57;
}

.timeline-item.long-term::before {
  background: #48dbfb;
}

.timeline-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding: 15px 20px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.timeline-header h4 {
  margin: 0;
  color: #333;
  font-size: 1.2rem;
}

.timeline-duration {
  background: #e9ecef;
  color: #495057;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 500;
}

.timeline-content {
  background: white;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.roadmap-item {
  padding: 20px;
  margin-bottom: 15px;
  background: #f8f9fa;
  border-radius: 8px;
  border-left: 3px solid #dee2e6;
  transition: all 0.3s ease;
}

.roadmap-item:hover {
  transform: translateX(5px);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.roadmap-item:last-child {
  margin-bottom: 0;
}

.issue,
.goal {
  font-weight: 600;
  color: #333;
  margin-bottom: 10px;
  font-size: 1rem;
}

.solution {
  color: #555;
  line-height: 1.5;
  margin-bottom: 15px;
}

.resources,
.actions,
.techniques {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.resource-tag,
.action-tag,
.technique-tag {
  padding: 4px 10px;
  border-radius: 15px;
  font-size: 0.8rem;
  font-weight: 500;
}

.resource-tag {
  background: #e3f2fd;
  color: #1976d2;
}

.action-tag {
  background: #fff3e0;
  color: #f57c00;
}

.technique-tag {
  background: #e8f5e8;
  color: #388e3c;
}

.immediate .roadmap-item {
  border-left-color: #ff6b6b;
}

.short-term .roadmap-item {
  border-left-color: #feca57;
}

.long-term .roadmap-item {
  border-left-color: #48dbfb;
}

@media (max-width: 768px) {
  .timeline-item {
    padding-left: 60px;
  }

  .roadmap-timeline::before {
    left: 20px;
  }

  .timeline-item::before {
    left: 8px;
  }

  .timeline-header {
    flex-direction: column;
    gap: 10px;
    text-align: center;
  }
}
</style>